package webSpider.webMagic;

import java.util.LinkedList;
import java.util.List;


import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;
import us.codecraft.webmagic.selector.Selectable;

public class NuomiPageProcessor implements PageProcessor {

    private Site site = Site.me().setRetryTimes(3);
    String filmName;
    @Override
    public void process(Page page) {
		//标题
//		String title = page.getHtml().xpath("/html/body/div[1]/div[2]/div[2]/a[1]/text()").toString();
		String title = page.getHtml().xpath("/html/body/div[3]/div[4]/div/div[1]/div/div[1]/div[2]/div[2]/div[1]/span[1]/a").toString();
//		page.putField("title", title);
		System.out.println(title);
//		 List<Selectable> filmUrls = page.getHtml().xpath("/html/body/div[2]/div[4]/div[1]/div[1]/h1").xpath("a/@href").nodes();
//    	 List<Information> inforList = new LinkedList<Information>();
//		 for(Selectable filmUrl:filmUrls){
//    		 page.addTargetRequest(filmUrl.toString());
//    		 filmName = page.getHtml().xpath("/html/body/div[6]/div[1]/div[1]/div/h2/a").toString();
//    		 List<Selectable> cinemaUrls = page.getHtml().xpath("/html/body/div[6]/div[1]/ul/li[1]/div[2]/div[1]/ul/li/div").nodes();
//    		 for(Selectable cinemaUrl:cinemaUrls){
//    			 String cinemaName = cinemaUrl.xpath("div/div[1]/div[1]/h3/a/text()").toString();
//    			 String strPrice = cinemaUrl.xpath("div/div[3]/div[1]/div/span[2]/text()").toString();
//    			 double price = Double.parseDouble(strPrice);
//    			 Information infor = new Information(cinemaName, price);
//    			 inforList.add(infor);
//    		 }
//    		 page.putField(filmName, inforList);
//    	 }
    }

    @Override
    public Site getSite() {
        return site;
    }
  
}

